﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using Spider.Entity;
using System.Collections;
using Winista.Text.HtmlParser.Lex;
using Winista.Text.HtmlParser;
using Winista.Text.HtmlParser.Util;
using Winista.Text.HtmlParser.Filters;


namespace Spider.Parser
{
    public class GanjiParser : ParserBase
    {
        protected override string GetContext(string html)
        {
            string reg = @"(?is)(?<=<ul class=""detail_info_ul"">).+?(?=</ul>)";
            string temp = Regex.Match(html, reg).Value;
            //移除标签中的内容 只要纯文本
            return Regex.Replace(temp, @"<[^>]*>", string.Empty, RegexOptions.IgnoreCase);

            //Lexer lexer = new Lexer(html);
            //NodeFilter filter = new HasAttributeFilter("class", "detail_info_ul");
            //Winista.Text.HtmlParser.Parser parser = new Winista.Text.HtmlParser.Parser(lexer);
            //NodeList nodeList = parser.Parse(filter);
            
            //if (nodeList.Count > 0)
            //    return nodeList[0].Children.AsString();
            //return "";
        }
    }

}
